luci.mk: refactor install recipe
authorJo-Philipp Wich <[email protected]>
Wed, 28 Sep 2022 07:17:06 +0000 (09:17 +0200)
committerJo-Philipp Wich <[email protected]>
Mon, 3 Apr 2023 11:45:03 +0000 (13:45 +0200)
Detect the presence of directories using Make $(wildcard ...) and emit
plain install commands depending on the outcome instead of relying on
shell conditionals which impose syntax constraints on code outside of
the scope of the LuCI repo.

Fixes: #5936
Signed-off-by: Jo-Philipp Wich <[email protected]>
(cherry picked from commit 3393e15815f116b33e90b5f58050cfedebe00fe2)

luci.mk

diff --git a/luci.mk b/luci.mk
index 7fa1e215bcab1d40abb40ed4a7310539e67e6efb..e143cac41568ae5d85f655f2f220763ef824f605 100644 (file)
--- a/luci.mk
+++ b/luci.mk
@@ -185,27 +185,28 @@ else
 endif
 
 define Package/$(PKG_NAME)/install
-       if [ -d $(PKG_BUILD_DIR)/luasrc ]; then \
-         $(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR); \
-         cp -pR $(PKG_BUILD_DIR)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/; \
-         $(FIND) $(1)$(LUCI_LIBRARYDIR)/ -type f -name '*.luadoc' | $(XARGS) rm; \
-         $(if $(CONFIG_LUCI_SRCDIET),$(call SrcDiet,$(1)$(LUCI_LIBRARYDIR)/),true); \
-         $(call SubstituteVersion,$(1)$(LUCI_LIBRARYDIR)/); \
-       else true; fi
-       if [ -d $(PKG_BUILD_DIR)/htdocs ]; then \
-         $(INSTALL_DIR) $(1)$(HTDOCS); \
-         cp -pR $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/; \
-         $(if $(CONFIG_LUCI_JSMIN),$(call JsMin,$(1)$(HTDOCS)/),true); \
-         $(if $(CONFIG_LUCI_CSSTIDY),$(call CssTidy,$(1)$(HTDOCS)/),true); \
-       else true; fi
-       if [ -d $(PKG_BUILD_DIR)/root ]; then \
-         $(INSTALL_DIR) $(1)/; \
-         cp -pR $(PKG_BUILD_DIR)/root/* $(1)/; \
-       else true; fi
-       if [ -d $(PKG_BUILD_DIR)/src ]; then \
-         $(call Build/Install/Default) \
-         $(CP) $(PKG_INSTALL_DIR)/* $(1)/; \
-       else true; fi
+
+ ifneq ($(wildcard ${CURDIR}/luasrc),)
+       $(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR)
+       cp -pR $(PKG_BUILD_DIR)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/
+       $(FIND) $(1)$(LUCI_LIBRARYDIR)/ -type f -name '*.luadoc' | $(XARGS) rm
+       $(if $(CONFIG_LUCI_SRCDIET),$(call SrcDiet,$(1)$(LUCI_LIBRARYDIR)/),true)
+       $(call SubstituteVersion,$(1)$(LUCI_LIBRARYDIR)/)
+ endif
+ ifneq ($(wildcard ${CURDIR}/htdocs),)
+       $(INSTALL_DIR) $(1)$(HTDOCS)
+       cp -pR $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/
+       $(if $(CONFIG_LUCI_JSMIN),$(call JsMin,$(1)$(HTDOCS)/),true)
+       $(if $(CONFIG_LUCI_CSSTIDY),$(call CssTidy,$(1)$(HTDOCS)/),true)
+ endif
+ ifneq ($(wildcard ${CURDIR}/root),)
+       $(INSTALL_DIR) $(1)/
+       cp -pR $(PKG_BUILD_DIR)/root/* $(1)/
+ endif
+ ifneq ($(wildcard ${CURDIR}/src),)
+       $(call Build/Install/Default)
+       $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+ endif
 endef
 
 ifndef Package/$(PKG_NAME)/postinst